package com.smartleanx.module.hrm.service.payrollapproverecord.listenser;

import com.smartleanx.module.bpm.event.BpmProcessInstanceStatusEvent;
import com.smartleanx.module.bpm.event.BpmProcessInstanceStatusEventListener;
import com.smartleanx.module.hrm.eums.employee.ProcessDefinitionEnum;
import com.smartleanx.module.hrm.service.payrollapproverecord.PayrollApproveRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 薪资离职流程状态监听器
 */
@Slf4j
@Component
public class BpmPayrollApproveListener extends BpmProcessInstanceStatusEventListener {

    @Resource
    private PayrollApproveRecordService payrollApproveRecordService;


    @Override
    protected String getProcessDefinitionKey() {
        return ProcessDefinitionEnum.PAYROLL_APPROVE.getKey();
    }

    @Override
    protected void onEvent(BpmProcessInstanceStatusEvent event) {
        payrollApproveRecordService.updateApproveResult(Long.valueOf(event.getBusinessKey()), event.getStatus());
    }
}
